package com.xuxu.product.config;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;

/**
 * @className: RestConfig
 * @author: Maxuxu
 * @date: 2022/8/18 9:04
 * @description: Es的配置类
 */
public class RestConfig extends AbstractElasticsearchConfiguration {
    @Override
    public RestHighLevelClient elasticsearchClient() {
        ClientConfiguration clientConfiguration = ClientConfiguration.builder()
                .connectedTo("localhost:9200").withBasicAuth("elastic", "maxuxu2000")
                .build();
        return RestClients.create(clientConfiguration).rest();
    }
}
